<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<html>
<base href="<%=basePath%>">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>众筹管理后台</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/dashboard.css" />
<link rel="stylesheet" href="css/dialog.css" />
<link rel="stylesheet" href="css/toastr.css" />
</head>
<body>
	<nav class="navbar navbar-inverse navbar-fixed-top">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed"
					data-toggle="collapse" data-target="#navbar" aria-expanded="false"
					aria-controls="navbar">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">众筹管理平台</a>
			</div>
			<div id="navbar" class="navbar-collapse collapse">

				<ul class="nav navbar-nav navbar-right">
					<li><a href="index.do">首页</a></li>
					<li><a href="javascript:void(0)">欢迎, ${login_admin.adminRealname }</a></li>
					<li><a href="admin/quit.do" title="退出登录">退出</a></li>
				</ul>
			</div>
		</div>
	</nav>

	<div class="container-fluid">
		<div class="row">
			<div class="col-sm-3 col-md-2 sidebar">
				<ul class="nav nav-sidebar">
					<li><a href="index.do">首页</a></li>
				</ul>
				<ul class="nav nav-sidebar">
					<li><a href="project/queryAll.do">所有项目</a></li>
					<li><a href="project/queryByType.do">项目审核</a></li>
					<li><a href="javascript:void(0)">项目跟踪</a></li>
					<li><a href="comment/queryAll.do">项目评论</a></li>
					<li class="active"><a href="classify/queryAll.do">项目分类</a></li>
					<li><a href="javascript:void(0)">项目推荐</a></li>
				</ul>
				<ul class="nav nav-sidebar">
					<li><a href="user/queryAll.do">注册用户</a></li>
					<li><a href="javascript:void(0)">用户资金</a></li>
					<li><a href="log.do">用户日志</a></li>
					<li><a href="user/queryByRole.do">实名审核</a></li>
				</ul>
				<ul class="nav nav-sidebar">
					<li><a href="javascript:void(0)">新闻管理</a></li>
					<li><a href="problem/queryAll.do">问题管理</a></li>
					<li><a href="admin/queryAll.do">管理用户</a></li>
					<li><a href="managelog.do">管理日志</a></li>
				</ul>
			</div>
			<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
				<h1 class="page-header">项目分类</h1>

				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="panel-title">
							项目分类列表 <a class="btn btn-primary" href="add_classity.do">添加</a>
						</div>
					</div>
					<div class="panel-body">

						<div class="table-responsive ">
							<table class="table table-striped table-bordered">
								<thead>
									<tr>
										<th>序号</th>
										<th>分类名称</th>
										<th>分类描述</th>
										<th>添加时间</th>
										<th>分类状态</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${p.list }" var="type">
										<tr>
											<td>${type.pstId }</td>
											<td>${type.pstName }</td>
											<td>${type.pstDesc }</td>
											<td><fmt:formatDate value="${type.pstStardate }"
													pattern="yy-MM-dd" /></td>
											<td>
											<c:if test="${type.pstType==0 }">可用</c:if>
											<c:if test="${type.pstType==1 }">不可用</c:if>
											</td>
											<td><a href="#" data-toggle="modal"
												data-target="#myModal"
												onclick="getTable(${type.pstId },'${type.pstName }','${type.pstDesc }','<fmt:formatDate value="${type.pstStardate }"  pattern="yy-MM-dd" />','${type.pstType }')">详情/修改</a>
												| <a href="javascript:void(0)"
												onclick="getdel(${type.pstId })">删除</a></td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>
						<!-- 模态框 -->
						<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
							aria-labelledby="myModalLabel" aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal"
											aria-hidden="true">&times;</button>
										<h4 class="modal-title" id="myModalLabel">分类详情</h4>
									</div>
									<div class="modal-body">
										<div class="form">
											<form class="form-validate form-horizontal"
												id="feedback_form" method="post">
												<div class="form-group ">
													<label for="p_id" class="control-label col-lg-2">序号<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="p_id" type="text" readonly />
													</div>
												</div>

												<div class="form-group ">
													<label for="p_name" class="control-label col-lg-2">分类名称<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="p_name" type="text" />
													</div>
												</div>
												<div class="form-group ">
													<label for="p_des" class="control-label col-lg-2">分类描述<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="p_des" type="text" />
													</div>
												</div>
												<div class="form-group ">
													<label for="p_time" class="control-label col-lg-2">添加时间<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="p_time" type="text"
															readonly />
													</div>
												</div>

												<div class="form-group ">
													<label for="p_status" class="control-label col-lg-2">分类状态<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<select class="form-control m-bot15" id="p_status">
															<option value="0">可用</option>
															<option value="1">禁用</option>
														</select>
													</div>
												</div>
												<div class="form-group" style="text-align: right;">
													<div class="col-lg-offset-2 col-lg-10">
														<button class="btn btn-primary" type="button"
															onclick="updatetype()">保存</button>
														<button class="btn btn-default" type="reset">重置</button>
													</div>
												</div>
											</form>
										</div>
									</div>
								</div>
							</div>
						</div>
							<nav aria-label="Page navigation" class="text-center">
							<ul class="pagination">
								<li><a href="classify/queryAll.do?tr=${p.prePage }"
									aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
								</a></li>
								<li><span aria-hidden="true">${p.pageNum }/${p.pages }页</span></li>
								<c:if test="${p.pageNum<p.pages }">
								<li><a href="classify/queryAll.do?tr=${p.nextPage }"
									aria-label="Next"> <span aria-hidden="true">&raquo;</span>
								</a></li>
								</c:if>
							</ul>
						</nav>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
	<script type="text/javascript" src="js/jquery1.12.4.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/countUp.js"></script>
	<script type="text/javascript" src="js/dialog.js"></script>
	<script type="text/javascript" src="js/toastr.js"></script>
	<script>
			$(document).ready(function() {
				var options =  {  
					useEasing: true,
					  useGrouping: true,
					  separator: ',',
					  decimal: '.',
				};
				var demo = new CountUp('moneyCount', 10000, 208965, 0, 2.5, options);
				if(!demo.error) {  
					demo.start();
				} else {  
					console.error(demo.error);
				}
			});
			 function getTable(p_id,p_name,p_des,p_time,p_type){
			        document.getElementById("p_id").value=p_id;
			        document.getElementById("p_name").value=p_name;
			        document.getElementById("p_des").value=p_des;
			        document.getElementById("p_time").value=p_time;
			        document.getElementById("p_status").value=p_type;
			    }
			    function getdel(id){
			    	javascript:$('body').dailog({type:'danger',title:'错误.',discription:'您确定要删除ID为'+id+'的数据吗?'},
			            function(ret) {
			                if(ret.index===0){
			                	$.ajax({
						    		url:"classify/delete.do",
						    		type:"post",
						    		data:{"pstId":id},
						    		success:function(data){toastr.info(data);window.location.href = "classify/queryAll.do"; },
						    		error:function(){toastr.error("服务端错误")}
						    	});
			                };
			            })
			    }
			    function updatetype(){
			    	var pstId = $("#p_id").val();
			    	var pstName = $("#p_name").val();
			    	var pstType = $("#p_status").val();
			    	var pstDesc = $("#p_des").val();
			    	
			    	$.ajax({
			    		url:"classify/updateById.do",
			    		type:"post",
			    		data:{"pstId":pstId,"pstName":pstName,"pstType":pstType,"pstDesc":pstDesc},
			    		success:function(data){
			    			toastr.info(data)
			    			window.location.href = "classify/queryAll.do";
			    			},
			    		error:function(){toastr.error("服务端错误")}
			    		
			    	});
			    }
		</script>


</body>
</html>